{
  "$schema" : "http://json-schema.org/draft/2019-09/schema#",
  "title" : "Non Recurring Payments",
  "type" : "object",
  "additionalProperties" : false,
  "properties" : {
    "interfaceCategory" : {
      "type" : "string",
      "enum" : [ "Payments" ],
      "description" : "CMP categorisation of the job associated with this file."
    },
    "interfaceType" : {
      "type" : "string",
      "enum" : [ "Upload" ],
      "description" : "Sub-categorisation of the job"
    },
    "version" : {
      "type" : "number",
      "minimum" : 1.0,
      "maximum" : 1.0,
      "description" : "The current version of the generic extract file. This must match the corresponding outbound file."
    },
    "transformDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Timestamp indicating when the third-party response file was transformed into the CMP generic format."
    },
    "transmitDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Timestamp indicating when the response file was received from the third-party system."
    },
    "externalFileName" : {
      "type" : "string",
      "pattern" : "^([a-zA-Z0-9._-])+$",
      "maxLength" : 20,
      "description" : "The name of the file that was received from the external system."
    },
    "recordCount" : {
      "type" : "integer",
      "minimum" : 0,
      "description" : "The total number of payment records in the file."
    },
    "isoCurrencyCode" : {
      "type" : "string",
      "pattern" : "^([a-zA-Z]){3}",
      "minLength" : 3,
      "maxLength" : 3,
      "description" : "The ISO currency code for the monetary amounts that are specified in the header totalAmount and the detail amount fields."
    },
    "totalAmount" : {
      "type" : "number",
      "minimum" : 0.0,
      "maximum" : 9.9999999999E8,
      "description" : "The sum of the individual detail record amounts."
    },
    "paymentSource" : {
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 10,
      "description" : "This represents the source of the payment e.g. the financial institution that the payment file has come from."
    },
    "details" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/Detail"
      }
    }
  },
  "required" : [ "interfaceCategory", "interfaceType", "version", "externalFileName", "recordCount", "isoCurrencyCode", "totalAmount", "paymentSource" ],
  "definitions" : {
    "Detail" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "detailSequence" : {
          "type" : "integer",
          "minimum" : 0,
          "description" : "Unique identifier of the detail record within the current extract. Starts at 1 and incremented for each detail record"
        },
        "accountReference" : {
          "type" : "string",
          "maxLength" : 12,
          "description" : "Can either be an account number, account serial number or can be 0. If Not 0/empty & is less than 8 long then represents an account number if = 0 or empty then this is not a valid account number so it goes to unallocated cash. if >8 then this is taken to represent an account serial number. This will then be used to lookup an account serial number (the specific one will be dictated by a properties file) in order to get the corresponding account number."
        },
        "amount" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : "This represents the amount that the payement is for. This must be a positive value."
        },
        "remark" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "This will be stored in the ledger along with the payment."
        },
        "paymentDateTime" : {
          "type" : "string",
          "format" : "date-time",
          "description" : "The date and time that the payment was made. It is important that a date is supplied for auditing purposes however if a valid date is not available this field should not be populated."
        },
        "description" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "Generally used for information that was contained in the original file that is not on this interface but which is worth storing in CMP. The data stored in this field will differ depending on the 3rd party source file."
        },
        "invoiceNumber" : {
          "type" : "integer",
          "minimum" : 0,
          "maximum" : 2147483648,
          "description" : "The invoice number if supplied will be used for matching the payment off against the appropriate invoice and in this case will be subject to standard cash match algorithms in the ledger."
        }
      },
      "required" : [ "detailSequence", "amount", "remark" ]
    }
  }
}